package com.equipment;

import com.util.EncodingUtil;

/**
 * 卡片复位指令 FDA1
 * @version 1.18
 * @author 刘亚东
 *
 */
public class ColdResetRequest {

	private String STX = "55AA"; // 帧开始标志
	private String RSCTL = "00"; // 串口帧序列号
	private String Length="";	//长度
	private String code = "FD"; // 代码
	private String broadening = "A1"; // 扩展代码
	private String BCC = ""; // 异或校验值

	private String PsamNum = ""; // PSAM卡号（1~4），接触式大卡号 0，非接触卡号0xff

	/**
	 * 发送A1指令
	 *
	 * @param pasmNum
	 * @return
	 */
	public String command(String pasmNum) {
		this.PsamNum = EncodingUtil.desToHex(Integer.parseInt(pasmNum), 2); // PSAM卡号（1~4），接触式大卡号
		Length=EncodingUtil.desToHex((broadening+PsamNum).length()/2, 4);																// 0，非接触卡号0xff
		// DATA由代码+扩展子代码+目录编号+随机数长度按顺序拼接组成
		String DATA =RSCTL+Length+code + broadening + PsamNum;
		// 异或校验从RSCTL到DATA所有字节的异或值
		BCC = EncodingUtil.yihuo(EncodingUtil.change(DATA));
		// 拼接完整的请求
		String retn = STX + DATA + BCC ;
		return retn;
	}

	public String getSTX() {
		return STX;
	}

	public void setSTX(String sTX) {
		STX = sTX;
	}

	public String getRSCTL() {
		return RSCTL;
	}

	public void setRSCTL(String rSCTL) {
		RSCTL = rSCTL;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getBroadening() {
		return broadening;
	}

	public void setBroadening(String broadening) {
		this.broadening = broadening;
	}

	public String getBCC() {
		return BCC;
	}

	public void setBCC(String bCC) {
		BCC = bCC;
	}

	public String getPsamNum() {
		return PsamNum;
	}

	public void setPsamNum(String psamNum) {
		PsamNum = psamNum;
	}

}
